
require('./myen.less')
require('../../assets/css/reset.css')
require('../../assets/css/normalize.css')
require('../../assets/iconf/iconfont.css')
require('../../assets/css/basic.less')
let footer = require('../../lib/utlis/footer')
let axios = require('axios')


// 获取登录时储存的用户信息
let user = JSON.parse(localStorage.getItem('login'))
// 设置axios请求头,添加token
axios.defaults.headers.authorization = "Bearer " + user.token;
footer.footer('myen')

let nickName = document.querySelector('.nickName')
let sign = document.querySelector('.sign')
let duration = document.querySelector('.duration')
let calorie = document.querySelector('.calorie')
let tou = document.querySelector('.tou')
let header = document.querySelector('.header')
let esc = document.querySelector('.esc')
let sportTop = document.querySelector('.sportTop')
let badge = document.querySelector('.badge')

axios.get('http://47.96.154.185:3701/api/user/info')
    .then(function (res) {
        console.log(res);
        if (res.data.errno == 0) {
            tou.src = `http://47.96.154.185:3701${res.data.data.imgUrl}`
            nickName.textContent = res.data.data.nickName
            res.data.data.sign == '' ? '' : sign.textContent = res.data.data.sign
            duration.textContent = res.data.data.duration
            calorie.textContent = res.data.data.calorie
        }
    })
header.addEventListener('click', function () {
    location.href = './datum.html'
})

esc.addEventListener('click', function () {
    localStorage.removeItem('login')
    location.href = './reg.html'
})

sportTop.addEventListener('click',function(){
    location.href = './sportData.html'
})

badge.addEventListener('click',function(){
    location.href = './myBadge.html'
})